<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>module OpenURI::OpenRead - open-uri: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="module">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-i-open">#open</a>
    <li ><a href="#method-i-read">#read</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="module-OpenURI::OpenRead">
    <h1 id="module-OpenURI::OpenRead" class="module">
      module OpenURI::OpenRead
    </h1>

    <section class="description">
    
<p>Mixin for HTTP and FTP URIs.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-open" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">open</span><span
                                class="method-args">(*rest, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p><a href="OpenRead.html#method-i-open"><code>OpenURI::OpenRead#open</code></a> provides ‘open’ for <a href="../URI/HTTP.html"><code>URI::HTTP</code></a> and <a href="../URI/FTP.html"><code>URI::FTP</code></a>.</p>

<p><a href="OpenRead.html#method-i-open"><code>OpenURI::OpenRead#open</code></a> takes optional 3 arguments as:</p>

<pre class="ruby"><span class="ruby-constant">OpenURI</span><span class="ruby-operator">::</span><span class="ruby-constant">OpenRead</span><span class="ruby-comment">#open([mode [, perm]] [, options]) [{|io| ... }]</span>
</pre>

<p><a href="OpenRead.html#method-i-open"><code>OpenURI::OpenRead#open</code></a> returns an IO-like object if block is not given. Otherwise it yields the IO object and return the value of the block. The IO object is extended with <a href="Meta.html"><code>OpenURI::Meta</code></a>.</p>

<p><code>mode</code> and <code>perm</code> are the same as Kernel#open.</p>

<p>However, <code>mode</code> must be read mode because <a href="OpenRead.html#method-i-open"><code>OpenURI::OpenRead#open</code></a> doesn’t support write mode (yet). Also <code>perm</code> is ignored because it is meaningful only for file creation.</p>

<p><code>options</code> must be a hash.</p>

<p>Each option with a string key specifies an extra header field for HTTP. I.e., it is ignored for FTP without HTTP proxy.</p>

<p>The hash may include other options, where keys are symbols:</p>
<dl class="rdoc-list label-list"><dt>:proxy
<dd>
<p>Synopsis:</p>

<pre>:proxy =&gt; &quot;http://proxy.foo.com:8000/&quot;
:proxy =&gt; URI.parse(&quot;http://proxy.foo.com:8000/&quot;)
:proxy =&gt; true
:proxy =&gt; false
:proxy =&gt; nil</pre>

<p>If :proxy option is specified, the value should be String, <a href="../URI.html"><code>URI</code></a>, boolean or nil.</p>

<p>When String or <a href="../URI.html"><code>URI</code></a> is given, it is treated as proxy <a href="../URI.html"><code>URI</code></a>.</p>

<p>When true is given or the option itself is not specified, environment variable ‘scheme_proxy’ is examined. ‘scheme’ is replaced by ‘http’, ‘https’ or ‘ftp’.</p>

<p>When false or nil is given, the environment variables are ignored and connection will be made to a server directly.</p>
</dd><dt>:proxy_http_basic_authentication
<dd>
<p>Synopsis:</p>

<pre>:proxy_http_basic_authentication =&gt;
  [&quot;http://proxy.foo.com:8000/&quot;, &quot;proxy-user&quot;, &quot;proxy-password&quot;]
:proxy_http_basic_authentication =&gt;
  [URI.parse(&quot;http://proxy.foo.com:8000/&quot;),
   &quot;proxy-user&quot;, &quot;proxy-password&quot;]</pre>

<p>If :proxy option is specified, the value should be an Array with 3 elements.  It should contain a proxy <a href="../URI.html"><code>URI</code></a>, a proxy user name and a proxy password.  The proxy <a href="../URI.html"><code>URI</code></a> should be a String, an <a href="../URI.html"><code>URI</code></a> or nil.  The proxy user name and password should be a String.</p>

<p>If nil is given for the proxy <a href="../URI.html"><code>URI</code></a>, this option is just ignored.</p>

<p>If :proxy and :proxy_http_basic_authentication is specified, ArgumentError is raised.</p>
</dd><dt>:http_basic_authentication
<dd>
<p>Synopsis:</p>

<pre class="ruby"><span class="ruby-value">:http_basic_authentication</span><span class="ruby-operator">=&gt;</span>[<span class="ruby-identifier">user</span>, <span class="ruby-identifier">password</span>]
</pre>

<p>If :http_basic_authentication is specified, the value should be an array which contains 2 strings: username and password. It is used for HTTP Basic authentication defined by RFC 2617.</p>
</dd><dt>:content_length_proc
<dd>
<p>Synopsis:</p>

<pre>:content_length_proc =&gt; lambda {|content_length| ... }</pre>

<p>If :content_length_proc option is specified, the option value procedure is called before actual transfer is started. It takes one argument, which is expected content length in bytes.</p>

<p>If two or more transfers are performed by HTTP redirection, the procedure is called only once for the last transfer.</p>

<p>When expected content length is unknown, the procedure is called with nil.  This happens when the HTTP response has no Content-Length header.</p>
</dd><dt>:progress_proc
<dd>
<p>Synopsis:</p>

<pre>:progress_proc =&gt; lambda {|size| ...}</pre>

<p>If :progress_proc option is specified, the proc is called with one argument each time when ‘open’ gets content fragment from network. The argument <code>size</code> is the accumulated transferred size in bytes.</p>

<p>If two or more transfer is done by HTTP redirection, the procedure is called only one for a last transfer.</p>

<p>:progress_proc and :content_length_proc are intended to be used for progress bar. For example, it can be implemented as follows using Ruby/ProgressBar.</p>

<pre>pbar = nil
open(&quot;http://...&quot;,
  :content_length_proc =&gt; lambda {|t|
    if t &amp;&amp; 0 &lt; t
      pbar = ProgressBar.new(&quot;...&quot;, t)
      pbar.file_transfer_mode
    end
  },
  :progress_proc =&gt; lambda {|s|
    pbar.set s if pbar
  }) {|f| ... }</pre>
</dd><dt>:read_timeout
<dd>
<p>Synopsis:</p>

<pre>:read_timeout=&gt;nil     (no timeout)
:read_timeout=&gt;10      (10 second)</pre>

<p>:read_timeout option specifies a timeout of read for http connections.</p>
</dd><dt>:open_timeout
<dd>
<p>Synopsis:</p>

<pre>:open_timeout=&gt;nil     (no timeout)
:open_timeout=&gt;10      (10 second)</pre>

<p>:open_timeout option specifies a timeout of open for http connections.</p>
</dd><dt>:ssl_ca_cert
<dd>
<p>Synopsis:</p>

<pre>:ssl_ca_cert=&gt;filename or an Array of filenames</pre>

<p>:ssl_ca_cert is used to specify CA certificate for SSL. If it is given, default certificates are not used.</p>
</dd><dt>:ssl_verify_mode
<dd>
<p>Synopsis:</p>

<pre class="ruby"><span class="ruby-value">:ssl_verify_mode</span><span class="ruby-operator">=&gt;</span><span class="ruby-identifier">mode</span>
</pre>

<p>:ssl_verify_mode is used to specify openssl verify mode.</p>
</dd><dt>:ssl_min_version
<dd>
<p>Synopsis:</p>

<pre class="ruby"><span class="ruby-value">:ssl_min_version</span><span class="ruby-operator">=&gt;</span><span class="ruby-value">:TLS1_2</span>
</pre>

<p>:ssl_min_version option specifies the minimum allowed SSL/TLS protocol version.  See also OpenSSL::SSL::SSLContext#min_version=.</p>
</dd><dt>:ssl_max_version
<dd>
<p>Synopsis:</p>

<pre class="ruby"><span class="ruby-value">:ssl_max_version</span><span class="ruby-operator">=&gt;</span><span class="ruby-value">:TLS1_2</span>
</pre>

<p>:ssl_max_version option specifies the maximum allowed SSL/TLS protocol version.  See also OpenSSL::SSL::SSLContext#max_version=.</p>
</dd><dt>:ftp_active_mode
<dd>
<p>Synopsis:</p>

<pre class="ruby"><span class="ruby-value">:ftp_active_mode</span><span class="ruby-operator">=&gt;</span><span class="ruby-identifier">bool</span>
</pre>

<p><code>:ftp_active_mode =&gt; true</code> is used to make ftp active mode. Ruby 1.9 uses passive mode by default. Note that the active mode is default in Ruby 1.8 or prior.</p>
</dd><dt>:redirect
<dd>
<p>Synopsis:</p>

<pre class="ruby"><span class="ruby-value">:redirect</span><span class="ruby-operator">=&gt;</span><span class="ruby-identifier">bool</span>
</pre>

<p><code>:redirect</code> is true by default.  <code>:redirect =&gt; false</code> is used to disable all HTTP redirects.</p>

<p><a href="HTTPRedirect.html"><code>OpenURI::HTTPRedirect</code></a> exception raised on redirection. Using <code>true</code> also means that redirections between http and ftp are permitted.</p>
</dd></dl>

                              <div class="method-source-code" id="open-source">
            <pre><span class="ruby-comment"># File open-uri.rb, line 743</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">open</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">rest</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-constant">OpenURI</span>.<span class="ruby-identifier">open_uri</span>(<span class="ruby-keyword">self</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">rest</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-read" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">read</span><span
                                class="method-args">(options={})</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p><a href="OpenRead.html#method-i-read"><code>OpenURI::OpenRead#read</code></a>([ options ]) reads a content referenced by self and returns the content as string. The string is extended with <a href="Meta.html"><code>OpenURI::Meta</code></a>. The argument <code>options</code> is same as <a href="OpenRead.html#method-i-open"><code>OpenURI::OpenRead#open</code></a>.</p>

                              <div class="method-source-code" id="read-source">
            <pre><span class="ruby-comment"># File open-uri.rb, line 751</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">read</span>(<span class="ruby-identifier">options</span>={})
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">options</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">str</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">read</span>
    <span class="ruby-constant">Meta</span>.<span class="ruby-identifier">init</span> <span class="ruby-identifier">str</span>, <span class="ruby-identifier">f</span>
    <span class="ruby-identifier">str</span>
  }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

